package com.lf.data;

/**
 * Created by 严秋旺 on 2015/1/11.<br />
 * 分页对象
 */
public class Page extends Bean {
    /**
     * 总页数
     */
//    @Key(keyType = KeyType.PropertyKey, check = Validate.NUMBER, valueType = ValueType.Integer, nullable = true)
    private int count = 0;
    /**
     * 页号
     */
    @Key(keyType = KeyType.PropertyKey, check = Validate.NUMBER, valueType = ValueType.Integer, nullable = true)
    private int index = 1;
    /**
     * 页记录数
     */
    @Key(keyType = KeyType.PropertyKey, check = Validate.NUMBER, valueType = ValueType.Integer, nullable = true)
    private int size = 10;
    /**
     * 总记录数
     */
//    @Key(keyType = KeyType.PropertyKey, check = Validate.NUMBER, valueType = ValueType.Integer, nullable = true)
    private int sum = 0;

    /**
     * 获取总页数
     *
     * @return 总页数
     */
    public int getCount() {
        return count;
    }

    /**
     * 设置总页数
     *
     * @param count
     */
    public void setCount(Integer count) {
        if (count > 0) {
            this.count = count;
        }
    }

    /**
     * 获取页号
     *
     * @return 页号
     */
    public int getIndex() {
        return index;
    }

    /**
     * 设置页号
     *
     * @param index 页号
     */
    public void setIndex(Integer index) {
        if (index > 1) {
            this.index = index;
        }
    }

    /**
     * 获取页记录数
     *
     * @return 页记录数
     */
    public int getSize() {
        return size;
    }

    /**
     * 设置页记录数
     *
     * @param size 页记录数
     */
    public void setSize(Integer size) {
        if (size > 0) {
            this.size = size;
        }
    }

    /**
     * 设置总记录数
     *
     * @return 总记录数
     */
    public int getSum() {
        return sum;
    }

    /**
     * 设置总记录数
     *
     * @param sum 总记录数   u
     */
    public void setSum(Integer sum) {
        this.sum = sum;
        count = sum / size;
        if (sum % size > 0) {
            count++;
        }
        if (count == 0) {
            count++;
        }
    }
}
